--- title: "4、飞机降落" created: 2025-11-28 tags: - 算法 --- # 4、飞机降落 ## 题目 [飞机降落](https://www.lanqiao.cn/paper/3818/problem/3511/) ![[image-bd014e9a.png]] ## 思路分析 ![[image-2f07fc94.png]] ## 代码实现 ```cpp #include using namespace std; #define endl '\n' const int N=15; struct planes{ int t,d,l; }p[N]; bool st[N]; int T,n; // int ans[N]; void dfs(int u,int last,bool &success){ if(u>n){ //for(int i=1;i<=n;i++) cout<=last && !st[i]){//如果该飞机的最晚降落时间晚于last 就说明可以放 st[i]=true; // ans[u]=i; dfs(u+1,max(last,t)+l,success); st[i]=false; } } } int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>T; while(T--){ cin>>n; for(int i=1;i<=n;i++){ int t,d,l; cin>>t>>d>>l; p[i]={t,d,l}; } memset(st,0,sizeof st); bool success=false; dfs(1,0,success); if(success) cout<<"YES"<